﻿using zijian666.Converts.Abstractions;
using zijian666.Converts.Convertor;
using zijian666.Converts.Core;

namespace zijian666.Converts;
internal class ObjectMappingConvertorFactory : IConvertorFactory
{

    /// <inheritdoc/>
    public MatchedConvertor<T> Create<T>()
    {
        var type = typeof(T);
        if (typeof(object) == type)
        {
            return new MatchedConvertor<T>(new ObjectMappingConvertor<T>(), MacthedType.Equals);
        }
        else if (ObjectConvertor<T>.CanBuild())
        {
            return new MatchedConvertor<T>(new ObjectMappingConvertor<T>(), MacthedType.TryCreate);
        }
        return default;
    }
}

